
#ifndef _INPREADER_H_
#define _INPREADER_H_


#include "ExchangeApi.hpp"
#include "../OLCore/AbstractFileReader.hpp"
#include "../OLApp/defines.hpp"
#include <string>
#include <iostream>
#include <vtkPoints.h>
#include <vtkUnstructuredGrid.h>

namespace NSDatax {
	class PartDataItem;
}

namespace NSExchange {


	class EXCHANGEAPI InpReaderTask : 
		public NSCore::AbstractFileReader
	{
		Q_OBJECT
	public:
		InpReaderTask(int id, QString filename) : NSCore::AbstractFileReader(id, filename) { };
		~InpReaderTask() override {};
		void run() override;
	/*override*/
	public:
		inline QString className() override { return "InpReaderTask"; };
		
	signals:
		void actionReadFinished(NSDatax::PartDataItem* /*item*/);
		void actionProgressChanged(int /*progress*/);

	private:
		QString extractElementType(QString input);
		QString extractSetIdentifier(QString pre, QString input);
		void readElements(Sp(vtkUnstructuredGrid) _ugrid, QStringList _data, QString _type);
		void readNodes(Sp(vtkPoints) _point, QStringList _data);

		typedef enum { 
			None = 0, 
			Nodes, 
			Elements,
			Nset,
			Elset
		} ReadState;

	};

}

#endif

